﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Spring.Context;
using Spring.Context.Support;

namespace YiLe.UI
{
    public partial class ContentViewControl : UserControl
    {
        /// <summary>
        /// Folder view
        /// </summary>
        private FolderView mFolderView;
        public FolderView FolderView
        {
            get
            {
                return mFolderView;
            }
            set
            {
                if (mFolderView != value)
                {
                    mFolderView = value;
                    OnFolderViewChanged();
                }
            }
        }
        /// <summary>
        /// Data Provider relate data information
        /// </summary>
        private DataProvider mDataProvider;
        public DataProvider DataProvider
        {
            get
            {
                return mDataProvider;
            }
            set
            {
                if (mDataProvider != value)
                {
                    mDataProvider = value;
                    this.OnDataProviderChanged();
                }
            }
        }
        protected virtual void OnDataProviderChanged()
        {

        }
        /// <summary>
        /// add for ApplicationContext, if get mContext is null, initialize the mContext 
        /// extend classes could use Context to build the Service instance.
        /// use for instead of DataProvider
        /// </summary>
        private IApplicationContext mContext;
        public IApplicationContext Context
        {
            get
            {
                if (mContext == null)
                {
                    mContext = ContextRegistry.GetContext();
                }
                return mContext;
            }
        }

        /// <summary>
        /// setting info save or load
        /// </summary>
        public virtual void SaveSettings()
        {

        }
        public virtual void LoadSettings()
        {

        }
        /// <summary>
        /// status bar info in the buttom
        /// </summary>
        public virtual string StatusBarInfo
        {
            get
            {
                return "";
            }
        }
        public virtual bool UpdateChanges()
        {
            return true;
        }
        /// <summary>
        /// data source bind for control
        /// </summary>
        public YiLeSystemData DataSource
        {
            get
            {
                if (mDataProvider != null)
                {
                    return mDataProvider.DataSet;
                }
                else
                {
                    return null;
                }
            }
        }
        protected virtual void OnFolderViewChanged()
        {

        }
        public virtual FolderView[] GetDefinedViews()
        {
            return null;
        }

        public virtual int ItemCount
        {
            get
            {
                return -1;
            }
        }
        /// <summary>
        /// print parts
        /// </summary>
        public virtual bool Printable
        {
            get
            {
                return false;
            }
        }
        public virtual void PrintPreview(Form ownerForm)
        {

        }

        public virtual void Print()
        {

        }
        /// <summary>
        /// item info, current item , delete, edit
        /// </summary>
        public event EventHandler CurrentItemChanged;
        protected virtual void OnCurrentItemChanged(EventArgs e)
        {
            if (CurrentItemChanged != null)
                CurrentItemChanged(this, e);
        }
        public virtual object CurrentItem
        {
            get
            {
                return null;
            }
        }
        public virtual bool CanDelete
        {
            get
            {
                return false;
            }
        }
        public virtual bool CanEdit
        {
            get
            {
                return false;
            }
        }


        public virtual void Delete()
        {

        }
        public virtual void Edit()
        {

        }
        public virtual Janus.Windows.UI.CommandBars.UICommandManager ControlCommandManager
        {
            get
            {
                return null;
            }
        }
        public virtual Janus.Windows.Ribbon.Ribbon RibbonControl
        {
            get
            {
                return null;
            }
        }
    }
}
